package com.ruoyi.web.controller.tongban;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.tongban.domain.FaceTvDevice;
import com.ruoyi.tongban.service.IFaceTvDeviceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 电视设备表Controller
 * 
 * @author ruoyi
 * @date 2021-04-21
 */
@RestController
@RequestMapping("/tongban/tvdevice")
public class FaceTvDeviceController extends BaseController
{
    @Autowired
    private IFaceTvDeviceService faceTvDeviceService;

    /**
     * 查询电视设备表列表
     */
    @PreAuthorize("@ss.hasPermi('tongban:tvdevice:list')")
    @GetMapping("/list")
    public TableDataInfo list(FaceTvDevice faceTvDevice)
    {
        startPage();
        List<FaceTvDevice> list = faceTvDeviceService.selectFaceTvDeviceList(faceTvDevice);
        return getDataTable(list);
    }

    /**
     * 导出电视设备表列表
     */
    @PreAuthorize("@ss.hasPermi('tongban:tvdevice:export')")
    @Log(title = "电视设备表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FaceTvDevice faceTvDevice)
    {
        List<FaceTvDevice> list = faceTvDeviceService.selectFaceTvDeviceList(faceTvDevice);
        ExcelUtil<FaceTvDevice> util = new ExcelUtil<FaceTvDevice>(FaceTvDevice.class);
        return util.exportExcel(list, "tvdevice");
    }

    /**
     * 获取电视设备表详细信息
     */
    @PreAuthorize("@ss.hasPermi('tongban:tvdevice:query')")
    @GetMapping(value = "/{tvDeviceId}")
    public AjaxResult getInfo(@PathVariable("tvDeviceId") Long tvDeviceId)
    {
        return AjaxResult.success(faceTvDeviceService.selectFaceTvDeviceById(tvDeviceId));
    }

    /**
     * 新增电视设备表
     */
    @PreAuthorize("@ss.hasPermi('tongban:tvdevice:add')")
    @Log(title = "电视设备表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FaceTvDevice faceTvDevice)
    {
        return toAjax(faceTvDeviceService.insertFaceTvDevice(faceTvDevice));
    }

    /**
     * 修改电视设备表
     */
    @PreAuthorize("@ss.hasPermi('tongban:tvdevice:edit')")
    @Log(title = "电视设备表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FaceTvDevice faceTvDevice)
    {
        return toAjax(faceTvDeviceService.updateFaceTvDevice(faceTvDevice));
    }

    /**
     * 删除电视设备表
     */
    @PreAuthorize("@ss.hasPermi('tongban:tvdevice:remove')")
    @Log(title = "电视设备表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tvDeviceIds}")
    public AjaxResult remove(@PathVariable Long[] tvDeviceIds)
    {
        return toAjax(faceTvDeviceService.deleteFaceTvDeviceByIds(tvDeviceIds));
    }
}
